using System.Linq;using System.Xml.Linq;using Medianamik.Core.Sugar;using Medianamik.Core;using Medianamik.Core.DAL;using System.Web;using Medianamik.Client.Data; /* Ajouter les Using nécessaires à la compilation */using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace Medianamik.UI.Web.Shop.Data
{
    [Serializable]
    public partial class BrandInterfaceRecordCollection : ReadOnlyList<BrandInterfaceRecord, BrandInterfaceRecordCollection>, ICollectionWithChildren<BrandInterfaceRecordCollection, BrandInterfaceRecord>
    {   
        public new IEnumerator<BrandInterfaceRecord> GetEnumerator()
         {
             return base.GetEnumerator();
         }
        #region Load with paging
        
        public BrandInterfaceRecordCollection Load(int pPageSize, int pPageIndex)
        {
            if (orderByCollection.Count == 0)
            {
                AddDefaultOrderBy();
            }
            
            Query qry = new Query(new BrandInterfaceRecord().GetSchema());
            CheckLogicalDelete(qry);
            foreach (Where where in wheres)
                qry.AddWhere(where);
            foreach (BetweenAnd between in betweens)
                qry.AddBetweenAnd(between);
            qry.OrderByCollection = orderByCollection;
            qry.PageSize = pPageSize;
            qry.PageIndex = pPageIndex;
            using (IDataReader rdr = qry.ExecuteReader())
            {
                LoadAndCloseReader(rdr);
                return this;
            }
        }
        
        public BrandInterfaceRecordCollection Load(string cultureName, ContentState contentState, ActiveStatus status)
        {
            wheres.RemoveAll(w => w.ColumnName.Equals("CultureName"));
            Where("CultureName", cultureName);
            wheres.RemoveAll(w => w.ColumnName.Equals("Generation"));
            Where("Generation", (int)contentState);
            wheres.RemoveAll(w => w.ColumnName.Equals("IsActive"));
            if(status != ActiveStatus.All)
            {
                Where("IsActive", status == ActiveStatus.Activated ? true : false);
            }
            
            return Load();
        }
        
        public BrandInterfaceRecordCollection Load(int pMaxElements)
        {
            return Load(pMaxElements, 1);
        }
        
        public BrandInterfaceRecordCollection Load(ContentState contentState)
        {
            wheres.RemoveAll(w => w.ColumnName.Equals("Generation"));
            Where("Generation", (int)contentState);
            return Load();
        }
        
        #endregion
        
        public IEnumerable<BrandInterfaceRecord> LoadByIDs(string ids)
        {
            return LoadByIDs(DataUtil.GetSelectedGuids(ids));
        }
        public IEnumerable<BrandInterfaceRecord> LoadByIDs(IList<Guid> ids)
        {
            if (ids.Count > 0)
            {
                if (ids.Count == 1)
                    Where("NodeId", ids.First());
                else
                    Where("NodeId", Comparison.In, ids.Select(g => g.ToString()));
                
                return Load().ReorderByIds(ids);
            }
            
            return Enumerable.Empty<BrandInterfaceRecord>();
        }
        
        public IEnumerable<BrandInterfaceRecord> LoadByIDs(string ids, string cultureName)
        {
            return LoadByIDs(DataUtil.GetSelectedGuids(ids), cultureName);
        }
        public IEnumerable<BrandInterfaceRecord> LoadByIDs(IList<Guid> ids, string cultureName)
        {
            wheres.RemoveAll(w => w.ColumnName.Equals("CultureName"));
            Where("CultureName", cultureName);
            
            return LoadByIDs(ids);
        }
        
        public IEnumerable<BrandInterfaceRecord> LoadByIDs(string ids, string cultureName, ContentState contentState, ActiveStatus status)
        {
            return LoadByIDs(DataUtil.GetSelectedGuids(ids), cultureName, contentState, status);
        }
        public IEnumerable<BrandInterfaceRecord> LoadByIDs(IList<Guid> ids, string cultureName, ContentState contentState, ActiveStatus status)
        {
            if (ids.Count > 0)
            {
                if (ids.Count == 1)
                    Where("NodeId", ids.First());
                else
                    Where("NodeId", Comparison.In, ids.Select(g => g.ToString()));
                return Load(cultureName, contentState, status)
                    .ReorderByIds(ids);
            }
            return Enumerable.Empty<BrandInterfaceRecord>();
        }
        
        public new BrandInterfaceRecordCollection Load()
        {
            if (orderByCollection.Count == 0)
            {
                AddDefaultOrderBy();
            }
            return base.Load();
        }
        private void AddDefaultOrderBy()
        {
            OrderByAsc("Position");
            OrderByDesc("CreatedOn");
        }
        public BrandInterfaceRecordCollection(ContentState state) : 
            this(System.Globalization.CultureInfo.CurrentUICulture.Name, default(Guid?), (int)state, ActiveStatus.Activated)
        { 
        }
         
        public BrandInterfaceRecordCollection() : 
            this(System.Globalization.CultureInfo.CurrentUICulture.Name, default(Guid?), default(int?), ActiveStatus.Activated) 
        {
        }
        
        public BrandInterfaceRecordCollection(Guid pTypeId) : 
            this(System.Globalization.CultureInfo.CurrentUICulture.Name, pTypeId, default(int?), ActiveStatus.Activated)
        {
        }
     
     
        public BrandInterfaceRecordCollection(string pCultureName) : 
            this(pCultureName, default(Guid?), default(int?), ActiveStatus.Activated)
        {
        }
        public BrandInterfaceRecordCollection(string pCultureName, Guid pTypeId) : 
            this(pCultureName, new Guid?(pTypeId), default(int?), ActiveStatus.Activated)
        {    
        }
        public BrandInterfaceRecordCollection(string pCultureName, ContentState state) : 
            this(pCultureName, default(Guid?),(int)state, ActiveStatus.Activated)
        {    
        }
        public BrandInterfaceRecordCollection(string pCultureName, Guid pTypeId, ContentState state) : 
            this(pCultureName, new Guid?(pTypeId), (int)state, ActiveStatus.Activated)
        {    
        }
     
        private BrandInterfaceRecordCollection(string pCultureName, Guid? pTypeId, int? pContentState, ActiveStatus status)
        {  
            if(pContentState.HasValue)
            {
                CurrentGeneration = pContentState.Value;
            }
            else
            {
                CurrentGeneration = System.Web.HttpContext.Current == null
                    ? (int)ContentState.Published
                    : new Medianamik.Client.Utility().GetGeneration(System.Web.HttpContext.Current.Request);
            }
            
            if(status != ActiveStatus.All)
        {
            Where("IsActive", status == ActiveStatus.Activated ? true : false);
        }
            Where("Generation", CurrentGeneration);
            Where("CultureName", pCultureName);
            if(pTypeId.HasValue)
            {
                Where("TypeId", pTypeId.Value);
            }
        } 
          
        public BrandInterfaceRecordCollection LoadParentNodes(Guid pNodeId) 
        {
            return LoadParentNodes(pNodeId, false, 0, (ContentState)CurrentGeneration, ActiveStatus.Activated);
        }
    
        public BrandInterfaceRecordCollection LoadParentNodes(Guid pNodeId, bool pInclusive) 
        {
            return LoadParentNodes(pNodeId, pInclusive, 0, (ContentState)CurrentGeneration, ActiveStatus.Activated);
        }
        
        public BrandInterfaceRecordCollection LoadParentNodes(Guid pNodeId, bool pInclusive, int pMaxDepth) 
        {
            return LoadParentNodes(pNodeId, pInclusive, pMaxDepth, (ContentState)CurrentGeneration, ActiveStatus.Activated);
        }
        public BrandInterfaceRecordCollection LoadParentNodes(Guid pNodeId, bool pInclusive, int pMaxDepth, ContentState contentState) 
        {
return LoadParentNodes(pNodeId, pInclusive, pMaxDepth, contentState, ActiveStatus.Activated);
        }
        public BrandInterfaceRecordCollection LoadParentNodes(Guid pNodeId, bool pInclusive, int pMaxDepth, ContentState contentState, ActiveStatus status) 
    {
     return LoadParentNodes(pNodeId, wheres.First(w => w.ColumnName.Equals("CultureName")).ParameterValue.ToString(),
        pInclusive, pMaxDepth, contentState, status);
    }
    
    public BrandInterfaceRecordCollection LoadParentNodes(Guid pNodeId, string cultureName, bool pInclusive, int pMaxDepth, 
            ContentState contentState, ActiveStatus status)
    {
        int isActiveValue = -1;
        switch (status)
        {
            case ActiveStatus.Activated:
                isActiveValue = 1;
                break;
            case ActiveStatus.Deactivated:
                isActiveValue = 0;
                break;
        }
        StoredProcedure sp = new StoredProcedure("medianamik_LoadParentNodes");
        sp.Command.AddParameter("@TableName", "vw_gen_BrandInterface", DbType.String);
        sp.Command.AddParameter("@NodeId", pNodeId, DbType.Guid);
        sp.Command.AddParameter("@CultureName", cultureName, DbType.String);
        sp.Command.AddParameter("@Generation", (int)contentState, DbType.Int32);
        sp.Command.AddParameter("@MaxDepth", pMaxDepth, DbType.Int32);
        sp.Command.AddParameter("@IsActive", isActiveValue, DbType.Int32);
        sp.Command.AddParameter("@InclusiveChar", DataUtil.GetSQLInclusivityOperator(pInclusive), DbType.String);
        IDataReader rdr = sp.GetReader();
        this.Load(rdr);
        rdr.Close();
        return this;
    }
    
        public BrandInterfaceRecordCollection LoadChildNodes(Guid pNodeId) 
        {
            return LoadChildNodes(pNodeId, false, 0, (ContentState)CurrentGeneration, ActiveStatus.Activated);
        }
    
        public BrandInterfaceRecordCollection LoadChildNodes(Guid pNodeId, bool pInclusive) 
        {
            return LoadChildNodes(pNodeId, pInclusive, 0, (ContentState)CurrentGeneration, ActiveStatus.Activated);
        }
        
        public BrandInterfaceRecordCollection LoadChildNodes(Guid pNodeId, bool pInclusive, int pMaxDepth)
        {
            return LoadChildNodes(pNodeId, pInclusive, pMaxDepth, (ContentState)CurrentGeneration, ActiveStatus.Activated);
        } 
        public BrandInterfaceRecordCollection LoadChildNodes(Guid pNodeId, bool pInclusive, int pMaxDepth, ContentState contentState)
        {
            return LoadChildNodes(pNodeId, pInclusive, pMaxDepth, contentState, ActiveStatus.Activated);
        }
        public BrandInterfaceRecordCollection LoadChildNodes(Guid pNodeId, bool pInclusive, int pMaxDepth, ContentState contentState, ActiveStatus status) 
    {
    return LoadChildNodes(pNodeId, wheres.First(w => w.ColumnName.Equals("CultureName")).ParameterValue.ToString(), pInclusive, pMaxDepth, contentState, status);
    }
    public BrandInterfaceRecordCollection LoadChildNodes(Guid pNodeId, string cultureName, bool pInclusive, int pMaxDepth, 
            ContentState contentState, ActiveStatus status)
    {
        int isActiveValue = -1;
        switch (status)
        {
            case ActiveStatus.Activated:
                isActiveValue = 1;
                break;
            case ActiveStatus.Deactivated:
                isActiveValue = 0;
                break;
        }
        StoredProcedure sp = new StoredProcedure("medianamik_LoadChildNodes");
        sp.Command.AddParameter("@TableName", "vw_gen_BrandInterface", DbType.String);
        sp.Command.AddParameter("@NodeId", pNodeId, DbType.Guid);
        sp.Command.AddParameter("@CultureName", cultureName, DbType.String);
        sp.Command.AddParameter("@Generation", contentState, DbType.Int32);
        sp.Command.AddParameter("@MaxDepth", pMaxDepth, DbType.Int32);
        sp.Command.AddParameter("@IsActive", isActiveValue, DbType.Int32);
        sp.Command.AddParameter("@InclusiveChar", DataUtil.GetSQLInclusivityOperator(pInclusive), DbType.String);
        IDataReader rdr = sp.GetReader();
        this.Load(rdr);
        rdr.Close();
        return this;
    }
     
         #region Constants
         
         public const string VIEW_NAME = "vw_gen_BrandInterface";
         public static readonly Guid InterfaceId = new Guid("f69da0ed-0e7c-4e00-9b28-64795eb42fd2");
           
         #endregion
     
         #region Properties
         
         public int CurrentGeneration
         {
            get; 
            private set;
         }
         
         #endregion  
    }
    [Serializable]
    public partial class BrandInterfaceRecord : ReadOnlyRecord<BrandInterfaceRecord>, IReadOnlyRecord, IRecordBase, IBrandInterface
    {
    
        #region Constants
        public const string VIEW_NAME = "vw_gen_BrandInterface";
        public static readonly Guid InterfaceId = new Guid("f69da0ed-0e7c-4e00-9b28-64795eb42fd2");
        private static readonly Medianamik.Core.Configuration.MedianamikConfigSection 
            CONFIG = (Medianamik.Core.Configuration.MedianamikConfigSection)System.Configuration
            .ConfigurationManager.GetSection(Medianamik.Core.ConfigurationSectionName.MEDIANAMIK);
        #endregion
     
        #region Properties
        public int CurrentGeneration
        {
            get;
            private set;
        }
        #endregion 
        
	    #region Default Settings
	    
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }
	    
	    #endregion
        #region Schema Accessor
        
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }
                
                return BaseSchema;
            }
        }
    	
        private static void GetTableSchema() 
        {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
                TableSchema.Table schema = new TableSchema.Table("vw_gen_BrandInterface", 
                    TableType.View, DataService.GetInstance("CodeGenerationProvider"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = "dbo";
                //columns
                
                TableSchema.TableColumn colvarId = new TableSchema.TableColumn(schema);
                colvarId.ColumnName = "Id";
                colvarId.DataType = DbType.Guid;
                colvarId.MaxLength = 0;
                colvarId.AutoIncrement = false;
                colvarId.IsNullable = false;
                colvarId.IsPrimaryKey = false;
                colvarId.IsForeignKey = false;
                colvarId.IsReadOnly = false;
                
                schema.Columns.Add(colvarId);
                
                TableSchema.TableColumn colvarNodeId = new TableSchema.TableColumn(schema);
                colvarNodeId.ColumnName = "NodeId";
                colvarNodeId.DataType = DbType.Guid;
                colvarNodeId.MaxLength = 0;
                colvarNodeId.AutoIncrement = false;
                colvarNodeId.IsNullable = false;
                colvarNodeId.IsPrimaryKey = false;
                colvarNodeId.IsForeignKey = false;
                colvarNodeId.IsReadOnly = false;
                
                schema.Columns.Add(colvarNodeId);
                
                TableSchema.TableColumn colvarRevision = new TableSchema.TableColumn(schema);
                colvarRevision.ColumnName = "Revision";
                colvarRevision.DataType = DbType.Int32;
                colvarRevision.MaxLength = 0;
                colvarRevision.AutoIncrement = false;
                colvarRevision.IsNullable = true;
                colvarRevision.IsPrimaryKey = false;
                colvarRevision.IsForeignKey = false;
                colvarRevision.IsReadOnly = false;
                
                schema.Columns.Add(colvarRevision);
                
                TableSchema.TableColumn colvarCultureName = new TableSchema.TableColumn(schema);
                colvarCultureName.ColumnName = "CultureName";
                colvarCultureName.DataType = DbType.String;
                colvarCultureName.MaxLength = 10;
                colvarCultureName.AutoIncrement = false;
                colvarCultureName.IsNullable = false;
                colvarCultureName.IsPrimaryKey = false;
                colvarCultureName.IsForeignKey = false;
                colvarCultureName.IsReadOnly = false;
                
                schema.Columns.Add(colvarCultureName);
                
                TableSchema.TableColumn colvarIsActive = new TableSchema.TableColumn(schema);
                colvarIsActive.ColumnName = "IsActive";
                colvarIsActive.DataType = DbType.Boolean;
                colvarIsActive.MaxLength = 0;
                colvarIsActive.AutoIncrement = false;
                colvarIsActive.IsNullable = false;
                colvarIsActive.IsPrimaryKey = false;
                colvarIsActive.IsForeignKey = false;
                colvarIsActive.IsReadOnly = false;
                
                schema.Columns.Add(colvarIsActive);
                
                TableSchema.TableColumn colvarIsSubEntity = new TableSchema.TableColumn(schema);
                colvarIsSubEntity.ColumnName = "IsSubEntity";
                colvarIsSubEntity.DataType = DbType.Boolean;
                colvarIsSubEntity.MaxLength = 0;
                colvarIsSubEntity.AutoIncrement = false;
                colvarIsSubEntity.IsNullable = false;
                colvarIsSubEntity.IsPrimaryKey = false;
                colvarIsSubEntity.IsForeignKey = false;
                colvarIsSubEntity.IsReadOnly = false;
                
                schema.Columns.Add(colvarIsSubEntity);
                
                TableSchema.TableColumn colvarGeneration = new TableSchema.TableColumn(schema);
                colvarGeneration.ColumnName = "Generation";
                colvarGeneration.DataType = DbType.Int32;
                colvarGeneration.MaxLength = 0;
                colvarGeneration.AutoIncrement = false;
                colvarGeneration.IsNullable = false;
                colvarGeneration.IsPrimaryKey = false;
                colvarGeneration.IsForeignKey = false;
                colvarGeneration.IsReadOnly = false;
                
                schema.Columns.Add(colvarGeneration);
                
                TableSchema.TableColumn colvarHasModifications = new TableSchema.TableColumn(schema);
                colvarHasModifications.ColumnName = "HasModifications";
                colvarHasModifications.DataType = DbType.Boolean;
                colvarHasModifications.MaxLength = 0;
                colvarHasModifications.AutoIncrement = false;
                colvarHasModifications.IsNullable = false;
                colvarHasModifications.IsPrimaryKey = false;
                colvarHasModifications.IsForeignKey = false;
                colvarHasModifications.IsReadOnly = false;
                
                schema.Columns.Add(colvarHasModifications);
                
                TableSchema.TableColumn colvarCreatedOn = new TableSchema.TableColumn(schema);
                colvarCreatedOn.ColumnName = "CreatedOn";
                colvarCreatedOn.DataType = DbType.DateTime;
                colvarCreatedOn.MaxLength = 0;
                colvarCreatedOn.AutoIncrement = false;
                colvarCreatedOn.IsNullable = false;
                colvarCreatedOn.IsPrimaryKey = false;
                colvarCreatedOn.IsForeignKey = false;
                colvarCreatedOn.IsReadOnly = false;
                
                schema.Columns.Add(colvarCreatedOn);
                
                TableSchema.TableColumn colvarDepth = new TableSchema.TableColumn(schema);
                colvarDepth.ColumnName = "Depth";
                colvarDepth.DataType = DbType.Int32;
                colvarDepth.MaxLength = 0;
                colvarDepth.AutoIncrement = false;
                colvarDepth.IsNullable = false;
                colvarDepth.IsPrimaryKey = false;
                colvarDepth.IsForeignKey = false;
                colvarDepth.IsReadOnly = false;
                
                schema.Columns.Add(colvarDepth);
                
                TableSchema.TableColumn colvarParentNodeId = new TableSchema.TableColumn(schema);
                colvarParentNodeId.ColumnName = "ParentNodeId";
                colvarParentNodeId.DataType = DbType.Guid;
                colvarParentNodeId.MaxLength = 0;
                colvarParentNodeId.AutoIncrement = false;
                colvarParentNodeId.IsNullable = true;
                colvarParentNodeId.IsPrimaryKey = false;
                colvarParentNodeId.IsForeignKey = false;
                colvarParentNodeId.IsReadOnly = false;
                
                schema.Columns.Add(colvarParentNodeId);
                
                TableSchema.TableColumn colvarPath = new TableSchema.TableColumn(schema);
                colvarPath.ColumnName = "Path";
                colvarPath.DataType = DbType.String;
                colvarPath.MaxLength = 500;
                colvarPath.AutoIncrement = false;
                colvarPath.IsNullable = false;
                colvarPath.IsPrimaryKey = false;
                colvarPath.IsForeignKey = false;
                colvarPath.IsReadOnly = false;
                
                schema.Columns.Add(colvarPath);
                
                TableSchema.TableColumn colvarPosition = new TableSchema.TableColumn(schema);
                colvarPosition.ColumnName = "Position";
                colvarPosition.DataType = DbType.Int16;
                colvarPosition.MaxLength = 0;
                colvarPosition.AutoIncrement = false;
                colvarPosition.IsNullable = false;
                colvarPosition.IsPrimaryKey = false;
                colvarPosition.IsForeignKey = false;
                colvarPosition.IsReadOnly = false;
                
                schema.Columns.Add(colvarPosition);
                
                TableSchema.TableColumn colvarTypeId = new TableSchema.TableColumn(schema);
                colvarTypeId.ColumnName = "TypeId";
                colvarTypeId.DataType = DbType.Guid;
                colvarTypeId.MaxLength = 0;
                colvarTypeId.AutoIncrement = false;
                colvarTypeId.IsNullable = false;
                colvarTypeId.IsPrimaryKey = false;
                colvarTypeId.IsForeignKey = false;
                colvarTypeId.IsReadOnly = false;
                
                schema.Columns.Add(colvarTypeId);
                
                TableSchema.TableColumn colvarModifiedOn = new TableSchema.TableColumn(schema);
                colvarModifiedOn.ColumnName = "ModifiedOn";
                colvarModifiedOn.DataType = DbType.DateTime;
                colvarModifiedOn.MaxLength = 0;
                colvarModifiedOn.AutoIncrement = false;
                colvarModifiedOn.IsNullable = true;
                colvarModifiedOn.IsPrimaryKey = false;
                colvarModifiedOn.IsForeignKey = false;
                colvarModifiedOn.IsReadOnly = false;
                
                schema.Columns.Add(colvarModifiedOn);
                
                TableSchema.TableColumn colvarCreatedBy = new TableSchema.TableColumn(schema);
                colvarCreatedBy.ColumnName = "CreatedBy";
                colvarCreatedBy.DataType = DbType.String;
                colvarCreatedBy.MaxLength = 100;
                colvarCreatedBy.AutoIncrement = false;
                colvarCreatedBy.IsNullable = true;
                colvarCreatedBy.IsPrimaryKey = false;
                colvarCreatedBy.IsForeignKey = false;
                colvarCreatedBy.IsReadOnly = false;
                
                schema.Columns.Add(colvarCreatedBy);
                
                TableSchema.TableColumn colvarExtendedData = new TableSchema.TableColumn(schema);
                colvarExtendedData.ColumnName = "ExtendedData";
                colvarExtendedData.DataType = DbType.AnsiString;
                colvarExtendedData.MaxLength = -1;
                colvarExtendedData.AutoIncrement = false;
                colvarExtendedData.IsNullable = false;
                colvarExtendedData.IsPrimaryKey = false;
                colvarExtendedData.IsForeignKey = false;
                colvarExtendedData.IsReadOnly = false;
                
                schema.Columns.Add(colvarExtendedData);
                
                TableSchema.TableColumn colvarName = new TableSchema.TableColumn(schema);
                colvarName.ColumnName = "Name";
                colvarName.DataType = DbType.AnsiString;
                colvarName.MaxLength = 100;
                colvarName.AutoIncrement = false;
                colvarName.IsNullable = true;
                colvarName.IsPrimaryKey = false;
                colvarName.IsForeignKey = false;
                colvarName.IsReadOnly = false;
                
                schema.Columns.Add(colvarName);
                
                TableSchema.TableColumn colvarImage = new TableSchema.TableColumn(schema);
                colvarImage.ColumnName = "Image";
                colvarImage.DataType = DbType.AnsiString;
                colvarImage.MaxLength = 500;
                colvarImage.AutoIncrement = false;
                colvarImage.IsNullable = true;
                colvarImage.IsPrimaryKey = false;
                colvarImage.IsForeignKey = false;
                colvarImage.IsReadOnly = false;
                
                schema.Columns.Add(colvarImage);
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["CodeGenerationProvider"].AddSchema("vw_gen_BrandInterface",schema);
            }
        }
        
        #endregion
        
        #region Query Accessor
        
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }
	    
	    #endregion
	    
	    #region .ctors
	    
	    public BrandInterfaceRecord()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }
        private BrandInterfaceRecord(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}
			
			MarkNew();
	    }
	    
	    private BrandInterfaceRecord(object keyID)
	    {
		    SetSQLProps();
		    LoadByKey(keyID);
	    }
    	 
	    private BrandInterfaceRecord(string columnName, object columnValue)
        {
            SetSQLProps();
            LoadByParam(columnName,columnValue);
        }
        
        public BrandInterfaceRecord(Guid pNodeId, string pCultureName, ContentState state) : 
            this(pNodeId, pCultureName, (int)state)
        { 
        }
        
        public BrandInterfaceRecord(Guid pNodeId, string pCultureName) : 
            this(pNodeId, pCultureName, default(int?))
        { 
        }
        public BrandInterfaceRecord(Guid pNodeId) : 
            this(pNodeId, System.Globalization.CultureInfo.CurrentUICulture.Name, default(int?))
        { 
        }
        
        private BrandInterfaceRecord(Guid pNodeId, string pCultureName, int? pContentState) : this()
        {
            if(pContentState.HasValue)
            {
                CurrentGeneration = pContentState.Value;
            }
            else
            {
                CurrentGeneration = System.Web.HttpContext.Current == null
                    ? (int)ContentState.Published
                    : new Medianamik.Client.Utility().GetGeneration(System.Web.HttpContext.Current.Request);
            }
            
            Query q = BrandInterfaceRecord.Query();
            q.WHERE("NodeId", pNodeId.ToString());
            q.WHERE("CultureName", pCultureName);
            q.WHERE("Generation", CurrentGeneration);
            this.LoadAndCloseReader(q.ExecuteReader());
        } 
        
        
        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("Id")]
        [Bindable(true)]
        public Guid Id 
        {
            get
            {
	            return GetColumnValue<Guid>("Id");
            }
            set
            {
                base.SetColumnValue("Id", value);
            }
        }
          
        [XmlAttribute("NodeId")]
        [Bindable(true)]
        public Guid NodeId 
        {
            get
            {
	            return GetColumnValue<Guid>("NodeId");
            }
            set
            {
                base.SetColumnValue("NodeId", value);
            }
        }
          
        [XmlAttribute("Revision")]
        [Bindable(true)]
        public int? Revision 
        {
            get
            {
	            return GetColumnValue<int?>("Revision");
            }
            set
            {
                base.SetColumnValue("Revision", value);
            }
        }
          
        [XmlAttribute("CultureName")]
        [Bindable(true)]
        public string CultureName 
        {
            get
            {
	            return GetColumnValue<string>("CultureName");
            }
            set
            {
                base.SetColumnValue("CultureName", value);
            }
        }
          
        [XmlAttribute("IsActive")]
        [Bindable(true)]
        public bool IsActive 
        {
            get
            {
	            return GetColumnValue<bool>("IsActive");
            }
            set
            {
                base.SetColumnValue("IsActive", value);
            }
        }
          
        [XmlAttribute("IsSubEntity")]
        [Bindable(true)]
        public bool IsSubEntity 
        {
            get
            {
	            return GetColumnValue<bool>("IsSubEntity");
            }
            set
            {
                base.SetColumnValue("IsSubEntity", value);
            }
        }
          
        [XmlAttribute("Generation")]
        [Bindable(true)]
        public int Generation 
        {
            get
            {
	            return GetColumnValue<int>("Generation");
            }
            set
            {
                base.SetColumnValue("Generation", value);
            }
        }
          
        [XmlAttribute("HasModifications")]
        [Bindable(true)]
        public bool HasModifications 
        {
            get
            {
	            return GetColumnValue<bool>("HasModifications");
            }
            set
            {
                base.SetColumnValue("HasModifications", value);
            }
        }
          
        [XmlAttribute("CreatedOn")]
        [Bindable(true)]
        public DateTime CreatedOn 
        {
            get
            {
	            return GetColumnValue<DateTime>("CreatedOn");
            }
            set
            {
                base.SetColumnValue("CreatedOn", value);
            }
        }
          
        [XmlAttribute("Depth")]
        [Bindable(true)]
        public int Depth 
        {
            get
            {
	            return GetColumnValue<int>("Depth");
            }
            set
            {
                base.SetColumnValue("Depth", value);
            }
        }
          
        [XmlAttribute("ParentNodeId")]
        [Bindable(true)]
        public Guid? ParentNodeId 
        {
            get
            {
	            return GetColumnValue<Guid?>("ParentNodeId");
            }
            set
            {
                base.SetColumnValue("ParentNodeId", value);
            }
        }
          
        [XmlAttribute("Path")]
        [Bindable(true)]
        public string Path 
        {
            get
            {
	            return GetColumnValue<string>("Path");
            }
            set
            {
                base.SetColumnValue("Path", value);
            }
        }
          
        [XmlAttribute("Position")]
        [Bindable(true)]
        public short Position 
        {
            get
            {
	            return GetColumnValue<short>("Position");
            }
            set
            {
                base.SetColumnValue("Position", value);
            }
        }
          
        [XmlAttribute("TypeId")]
        [Bindable(true)]
        public Guid TypeId 
        {
            get
            {
	            return GetColumnValue<Guid>("TypeId");
            }
            set
            {
                base.SetColumnValue("TypeId", value);
            }
        }
          
        [XmlAttribute("ModifiedOn")]
        [Bindable(true)]
        public DateTime? ModifiedOn 
        {
            get
            {
	            return GetColumnValue<DateTime?>("ModifiedOn");
            }
            set
            {
                base.SetColumnValue("ModifiedOn", value);
            }
        }
          
        [XmlAttribute("CreatedBy")]
        [Bindable(true)]
        public string CreatedBy 
        {
            get
            {
	            return GetColumnValue<string>("CreatedBy");
            }
            set
            {
                base.SetColumnValue("CreatedBy", value);
            }
        }
          
        [XmlAttribute("ExtendedData")]
        [Bindable(true)]
        public string ExtendedData 
        {
            get
            {
	            return GetColumnValue<string>("ExtendedData");
            }
            set
            {
                base.SetColumnValue("ExtendedData", value);
            }
        }
          
        [XmlAttribute("Name")]
        [Bindable(true)]
        public string Name 
        {
            get
            {
	            return GetColumnValue<string>("Name");
            }
            set
            {
                base.SetColumnValue("Name", value);
            }
        }
          
        [XmlAttribute("Image")]
        [Bindable(true)]
        public string Image 
        {
            get
            {
	            return GetColumnValue<string>("Image");
            }
            set
            {
                base.SetColumnValue("Image", value);
            }
        }
        
        
        #region foreign Relations
        
        
        
	    #endregion
	    
	    #endregion
	    
	    #region Methods
	    	    	    
	    public static BrandInterfaceRecord FetchByNodeID(Guid? pNodeId, string pCultureName, ContentState pState)
	    {
	        if(pNodeId.HasValue) { return new BrandInterfaceRecord(pNodeId.Value,pCultureName, pState); }
	        else return new BrandInterfaceRecord();
	    }
	    
	    #endregion
	    
        #region Columns Struct
        public struct Columns
        {
        
        public static string Id = @"Id";
        
        public static string NodeId = @"NodeId";
        
        public static string Revision = @"Revision";
        
        public static string CultureName = @"CultureName";
        
        public static string IsActive = @"IsActive";
        
        public static string IsSubEntity = @"IsSubEntity";
        
        public static string Generation = @"Generation";
        
        public static string HasModifications = @"HasModifications";
        
        public static string CreatedOn = @"CreatedOn";
        
        public static string Depth = @"Depth";
        
        public static string ParentNodeId = @"ParentNodeId";
        
        public static string Path = @"Path";
        
        public static string Position = @"Position";
        
        public static string TypeId = @"TypeId";
        
        public static string ModifiedOn = @"ModifiedOn";
        
        public static string CreatedBy = @"CreatedBy";
        
        public static string ExtendedData = @"ExtendedData";
        
        public static string Name = @"Name";
        
        public static string Image = @"Image";
        
        }
        #endregion
        #region IAbstractRecord Members
        public new CT GetColumnValue<CT>(string columnName) {
            return base.GetColumnValue<CT>(columnName);
        }
        public object GetColumnValue(string columnName) {
            return base.GetColumnValue<object>(columnName);
        }
        #endregion
    }
    
    
    public partial interface IBrandInterface : IMedianamikDTOWithName
    {
          
        string Image 
        {
        get;
        }
        
        
    
    }
    
    #region BasePage
     
    
    #endregion
}
